



// This code is a generated code by a tool
// designed and coded by Shohdi Mohamed Elsheemy ( shohdi@gmail.com )            

using System;
using System.Collections.Generic;
using System.Web;
using System.Data.Common;
using Shohdi.DataHandler;
using System.Data;




namespace DatabaseComponent
{
    
    public partial class CertificateDataDB
    {
         string _Connection = "";


        public string Connection
        {
            get { return _Connection; }
            set { _Connection = value; }
        }


       
         string _Provider = "System.Data.SqlClient";

        
        public string Provider
        {
            get { return _Provider; }
            set { _Provider = value; }
        }



        public CertificateDataDB()
        {
        }

        public CertificateDataDB(string __Connection,params string [] __Provider)
        {

            if (__Provider.Length > 0)
                _Provider = __Provider[0];

            _Connection = __Connection;
            
        }




        public List<CertificateData> Select(ClassDataHandler con, string strTop, string strWhere, params DbParameter[] whereParams)
        {
            if (whereParams == null)
                whereParams = new DbParameter[0];

            List<CertificateData> lstRet = new List<CertificateData>();

            string strQuery = " select " + strTop  + " * from dbo.[CertificateData]  " ;

            if (strWhere != "")
            {
                strQuery = strQuery + "  " + strWhere;
            }

            DbDataReader dr = con.SelectDataReader(strQuery, CommandType.Text, whereParams);


            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    CertificateData obj = new CertificateData();
 if (dr["ID"] != DBNull.Value)
                    {
                        obj.ID = (System.Int64)dr["ID"];
                    }
                    else
                    {
                        obj.ID = -1;
                    } 
 if (dr["IamLearningImage"] != DBNull.Value)
                    {
                        obj.IamLearningImage = (System.String)dr["IamLearningImage"];
                    }
                    else
                    {
                        obj.IamLearningImage = "";
                    } 
 if (dr["SECImage"] != DBNull.Value)
                    {
                        obj.SECImage = (System.String)dr["SECImage"];
                    }
                    else
                    {
                        obj.SECImage = "";
                    } 
 if (dr["SignImage"] != DBNull.Value)
                    {
                        obj.SignImage = (System.String)dr["SignImage"];
                    }
                    else
                    {
                        obj.SignImage = "";
                    } 
 if (dr["StampImage"] != DBNull.Value)
                    {
                        obj.StampImage = (System.String)dr["StampImage"];
                    }
                    else
                    {
                        obj.StampImage = "";
                    } 
 if (dr["ManagerPos"] != DBNull.Value)
                    {
                        obj.ManagerPos = (System.String)dr["ManagerPos"];
                    }
                    else
                    {
                        obj.ManagerPos = "";
                    } 
 if (dr["ManagerName"] != DBNull.Value)
                    {
                        obj.ManagerName = (System.String)dr["ManagerName"];
                    }
                    else
                    {
                        obj.ManagerName = "";
                    } 
 if (dr["ShowStamp"] != DBNull.Value)
                    {
                        obj.ShowStamp = (System.Boolean)dr["ShowStamp"];
                    }
                    else
                    {
                        obj.ShowStamp = false;
                    } 
 if (dr["ShowSignature"] != DBNull.Value)
                    {
                        obj.ShowSignature = (System.Boolean)dr["ShowSignature"];
                    }
                    else
                    {
                        obj.ShowSignature = false;
                    } 



                    lstRet.Add(obj);
                   

                }
            }

            dr.Close();


            return lstRet;
        }


        public List<CertificateData> Select(string strTop, string strWhere, params DbParameter[] whereParams)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<CertificateData> lstRet = Select(con, strTop, strWhere, whereParams);

            con.CloseConnection();

            return lstRet;
        }

        



        public void Insert(ClassDataHandler con , CertificateData obj)
        {
            
            

                    DbParameter prmIamLearningImage = con.createParameter();
                    prmIamLearningImage.ParameterName = "@IamLearningImage";
                    prmIamLearningImage.DbType =DbType.String;
                    if (obj.IamLearningImage == null)
                    {
                        prmIamLearningImage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmIamLearningImage.Value = obj.IamLearningImage;
                    }
                

                    


                    DbParameter prmSECImage = con.createParameter();
                    prmSECImage.ParameterName = "@SECImage";
                    prmSECImage.DbType =DbType.String;
                    if (obj.SECImage == null)
                    {
                        prmSECImage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmSECImage.Value = obj.SECImage;
                    }
                

                    


                    DbParameter prmSignImage = con.createParameter();
                    prmSignImage.ParameterName = "@SignImage";
                    prmSignImage.DbType =DbType.String;
                    if (obj.SignImage == null)
                    {
                        prmSignImage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmSignImage.Value = obj.SignImage;
                    }
                

                    


                    DbParameter prmStampImage = con.createParameter();
                    prmStampImage.ParameterName = "@StampImage";
                    prmStampImage.DbType =DbType.String;
                    if (obj.StampImage == null)
                    {
                        prmStampImage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmStampImage.Value = obj.StampImage;
                    }
                

                    


                    DbParameter prmManagerPos = con.createParameter();
                    prmManagerPos.ParameterName = "@ManagerPos";
                    prmManagerPos.DbType =DbType.String;
                    if (obj.ManagerPos == null)
                    {
                        prmManagerPos.Value = DBNull.Value;
                    }
                    else
                    {
                        prmManagerPos.Value = obj.ManagerPos;
                    }
                

                    


                    DbParameter prmManagerName = con.createParameter();
                    prmManagerName.ParameterName = "@ManagerName";
                    prmManagerName.DbType =DbType.String;
                    if (obj.ManagerName == null)
                    {
                        prmManagerName.Value = DBNull.Value;
                    }
                    else
                    {
                        prmManagerName.Value = obj.ManagerName;
                    }
                

                    


                    DbParameter prmShowStamp = con.createParameter();
                    prmShowStamp.ParameterName = "@ShowStamp";
                    prmShowStamp.DbType =DbType.Boolean;
                    if (obj.ShowStamp == null)
                    {
                        prmShowStamp.Value = DBNull.Value;
                    }
                    else
                    {
                        prmShowStamp.Value = obj.ShowStamp;
                    }
                

                    


                    DbParameter prmShowSignature = con.createParameter();
                    prmShowSignature.ParameterName = "@ShowSignature";
                    prmShowSignature.DbType =DbType.Boolean;
                    if (obj.ShowSignature == null)
                    {
                        prmShowSignature.Value = DBNull.Value;
                    }
                    else
                    {
                        prmShowSignature.Value = obj.ShowSignature;
                    }
                

                    


           



            string strQuery = " insert into dbo.[CertificateData] ([IamLearningImage],[SECImage],[SignImage],[StampImage],[ManagerPos],[ManagerName],[ShowStamp],[ShowSignature]) VALUES (@IamLearningImage,@SECImage,@SignImage,@StampImage,@ManagerPos,@ManagerName,@ShowStamp,@ShowSignature) ; select SCOPE_IDENTITY() ";
 object scope = con.ExecuteScalar(strQuery, CommandType.Text, prmIamLearningImage,prmSECImage,prmSignImage,prmStampImage,prmManagerPos,prmManagerName,prmShowStamp,prmShowSignature);


                    try
                    {
                        obj.ID = System.Int64.Parse(scope.ToString());
                    }
                    catch
                    {
                        obj.ID = -1;
                    }


                    


           

        }



        public void Insert(CertificateData obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Insert(con,obj);


            con.CloseConnection();
        }




        public void Update(ClassDataHandler con, CertificateData obj)
        {
            
            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


                    DbParameter prmIamLearningImage = con.createParameter();
                    prmIamLearningImage.ParameterName = "@IamLearningImage";
                    prmIamLearningImage.DbType =DbType.String;
                    if (obj.IamLearningImage == null)
                    {
                        prmIamLearningImage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmIamLearningImage.Value = obj.IamLearningImage;
                    }
                

                    


                    DbParameter prmSECImage = con.createParameter();
                    prmSECImage.ParameterName = "@SECImage";
                    prmSECImage.DbType =DbType.String;
                    if (obj.SECImage == null)
                    {
                        prmSECImage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmSECImage.Value = obj.SECImage;
                    }
                

                    


                    DbParameter prmSignImage = con.createParameter();
                    prmSignImage.ParameterName = "@SignImage";
                    prmSignImage.DbType =DbType.String;
                    if (obj.SignImage == null)
                    {
                        prmSignImage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmSignImage.Value = obj.SignImage;
                    }
                

                    


                    DbParameter prmStampImage = con.createParameter();
                    prmStampImage.ParameterName = "@StampImage";
                    prmStampImage.DbType =DbType.String;
                    if (obj.StampImage == null)
                    {
                        prmStampImage.Value = DBNull.Value;
                    }
                    else
                    {
                        prmStampImage.Value = obj.StampImage;
                    }
                

                    


                    DbParameter prmManagerPos = con.createParameter();
                    prmManagerPos.ParameterName = "@ManagerPos";
                    prmManagerPos.DbType =DbType.String;
                    if (obj.ManagerPos == null)
                    {
                        prmManagerPos.Value = DBNull.Value;
                    }
                    else
                    {
                        prmManagerPos.Value = obj.ManagerPos;
                    }
                

                    


                    DbParameter prmManagerName = con.createParameter();
                    prmManagerName.ParameterName = "@ManagerName";
                    prmManagerName.DbType =DbType.String;
                    if (obj.ManagerName == null)
                    {
                        prmManagerName.Value = DBNull.Value;
                    }
                    else
                    {
                        prmManagerName.Value = obj.ManagerName;
                    }
                

                    


                    DbParameter prmShowStamp = con.createParameter();
                    prmShowStamp.ParameterName = "@ShowStamp";
                    prmShowStamp.DbType =DbType.Boolean;
                    if (obj.ShowStamp == null)
                    {
                        prmShowStamp.Value = DBNull.Value;
                    }
                    else
                    {
                        prmShowStamp.Value = obj.ShowStamp;
                    }
                

                    


                    DbParameter prmShowSignature = con.createParameter();
                    prmShowSignature.ParameterName = "@ShowSignature";
                    prmShowSignature.DbType =DbType.Boolean;
                    if (obj.ShowSignature == null)
                    {
                        prmShowSignature.Value = DBNull.Value;
                    }
                    else
                    {
                        prmShowSignature.Value = obj.ShowSignature;
                    }
                

                    


           



            string strQuery = " update dbo.[CertificateData] set [IamLearningImage]=@IamLearningImage,[SECImage]=@SECImage,[SignImage]=@SignImage,[StampImage]=@StampImage,[ManagerPos]=@ManagerPos,[ManagerName]=@ManagerName,[ShowStamp]=@ShowStamp,[ShowSignature]=@ShowSignature where  [ID]=@ID  ";

            con.ExecuteNonQuery(strQuery, CommandType.Text,prmID,prmIamLearningImage,prmSECImage,prmSignImage,prmStampImage,prmManagerPos,prmManagerName,prmShowStamp,prmShowSignature);

            

        }


        public void Update(CertificateData obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Update(con, obj);


            con.CloseConnection();
        }



        public void Delete(ClassDataHandler con, CertificateData obj)
        {

            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


           



           



            string strQuery = " delete from dbo.[CertificateData]  where  [ID]=@ID  "; 
                        con.ExecuteNonQuery(strQuery, CommandType.Text,prmID );  

             



        }


        public void Delete( CertificateData obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            Delete(con, obj);

            con.CloseConnection();
        }





                    public List<CertificateData> getCertificateDataByID(ClassDataHandler con,System.Int64 ID)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();


                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType = DbType.Int64;
                        if (ID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmID.Value = ID;
                        }


                        lstRet = Select(con, "" , " where [ID]=@ID ", prmID);



                        return lstRet;

                    }


                    public List<CertificateData> getCertificateDataByID(System.Int64 ID)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCertificateDataByID(con, ID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<CertificateData> getCertificateDataByIamLearningImage(ClassDataHandler con,System.String IamLearningImage)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();


                        DbParameter prmIamLearningImage = con.createParameter();
                        prmIamLearningImage.ParameterName = "@IamLearningImage";
                        prmIamLearningImage.DbType = DbType.String;
                        if (IamLearningImage == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmIamLearningImage.Value = IamLearningImage;
                        }


                        lstRet = Select(con, "" , " where [IamLearningImage]=@IamLearningImage ", prmIamLearningImage);



                        return lstRet;

                    }


                    public List<CertificateData> getCertificateDataByIamLearningImage(System.String IamLearningImage)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCertificateDataByIamLearningImage(con, IamLearningImage);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<CertificateData> getCertificateDataBySECImage(ClassDataHandler con,System.String SECImage)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();


                        DbParameter prmSECImage = con.createParameter();
                        prmSECImage.ParameterName = "@SECImage";
                        prmSECImage.DbType = DbType.String;
                        if (SECImage == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmSECImage.Value = SECImage;
                        }


                        lstRet = Select(con, "" , " where [SECImage]=@SECImage ", prmSECImage);



                        return lstRet;

                    }


                    public List<CertificateData> getCertificateDataBySECImage(System.String SECImage)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCertificateDataBySECImage(con, SECImage);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<CertificateData> getCertificateDataBySignImage(ClassDataHandler con,System.String SignImage)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();


                        DbParameter prmSignImage = con.createParameter();
                        prmSignImage.ParameterName = "@SignImage";
                        prmSignImage.DbType = DbType.String;
                        if (SignImage == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmSignImage.Value = SignImage;
                        }


                        lstRet = Select(con, "" , " where [SignImage]=@SignImage ", prmSignImage);



                        return lstRet;

                    }


                    public List<CertificateData> getCertificateDataBySignImage(System.String SignImage)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCertificateDataBySignImage(con, SignImage);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<CertificateData> getCertificateDataByStampImage(ClassDataHandler con,System.String StampImage)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();


                        DbParameter prmStampImage = con.createParameter();
                        prmStampImage.ParameterName = "@StampImage";
                        prmStampImage.DbType = DbType.String;
                        if (StampImage == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmStampImage.Value = StampImage;
                        }


                        lstRet = Select(con, "" , " where [StampImage]=@StampImage ", prmStampImage);



                        return lstRet;

                    }


                    public List<CertificateData> getCertificateDataByStampImage(System.String StampImage)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCertificateDataByStampImage(con, StampImage);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<CertificateData> getCertificateDataByManagerPos(ClassDataHandler con,System.String ManagerPos)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();


                        DbParameter prmManagerPos = con.createParameter();
                        prmManagerPos.ParameterName = "@ManagerPos";
                        prmManagerPos.DbType = DbType.String;
                        if (ManagerPos == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmManagerPos.Value = ManagerPos;
                        }


                        lstRet = Select(con, "" , " where [ManagerPos]=@ManagerPos ", prmManagerPos);



                        return lstRet;

                    }


                    public List<CertificateData> getCertificateDataByManagerPos(System.String ManagerPos)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCertificateDataByManagerPos(con, ManagerPos);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<CertificateData> getCertificateDataByManagerName(ClassDataHandler con,System.String ManagerName)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();


                        DbParameter prmManagerName = con.createParameter();
                        prmManagerName.ParameterName = "@ManagerName";
                        prmManagerName.DbType = DbType.String;
                        if (ManagerName == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmManagerName.Value = ManagerName;
                        }


                        lstRet = Select(con, "" , " where [ManagerName]=@ManagerName ", prmManagerName);



                        return lstRet;

                    }


                    public List<CertificateData> getCertificateDataByManagerName(System.String ManagerName)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCertificateDataByManagerName(con, ManagerName);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<CertificateData> getCertificateDataByShowStamp(ClassDataHandler con,System.Boolean ShowStamp)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();


                        DbParameter prmShowStamp = con.createParameter();
                        prmShowStamp.ParameterName = "@ShowStamp";
                        prmShowStamp.DbType = DbType.Boolean;
                        if (ShowStamp == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmShowStamp.Value = ShowStamp;
                        }


                        lstRet = Select(con, "" , " where [ShowStamp]=@ShowStamp ", prmShowStamp);



                        return lstRet;

                    }


                    public List<CertificateData> getCertificateDataByShowStamp(System.Boolean ShowStamp)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCertificateDataByShowStamp(con, ShowStamp);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<CertificateData> getCertificateDataByShowSignature(ClassDataHandler con,System.Boolean ShowSignature)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();


                        DbParameter prmShowSignature = con.createParameter();
                        prmShowSignature.ParameterName = "@ShowSignature";
                        prmShowSignature.DbType = DbType.Boolean;
                        if (ShowSignature == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmShowSignature.Value = ShowSignature;
                        }


                        lstRet = Select(con, "" , " where [ShowSignature]=@ShowSignature ", prmShowSignature);



                        return lstRet;

                    }


                    public List<CertificateData> getCertificateDataByShowSignature(System.Boolean ShowSignature)
                    {
                        List<CertificateData> lstRet = new List<CertificateData>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCertificateDataByShowSignature(con, ShowSignature);

                        con.CloseConnection();

                        return lstRet;

                    }



                

            
public List<CertificateData> Search(ClassDataHandler con, CertificateData obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID AND ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.IamLearningImage != "")
                    {
                        DbParameter prmIamLearningImage = con.createParameter();
                        prmIamLearningImage.ParameterName = "@IamLearningImage";
                        prmIamLearningImage.DbType =DbType.String;
                        if (obj.IamLearningImage == null)
                        {
                            prmIamLearningImage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmIamLearningImage.Value = obj.IamLearningImage;
                        }
                        strWhere += " [IamLearningImage]=@IamLearningImage AND ";
                        lstParameters.Add(prmIamLearningImage);
                     }



                    

                    if (obj.SECImage != "")
                    {
                        DbParameter prmSECImage = con.createParameter();
                        prmSECImage.ParameterName = "@SECImage";
                        prmSECImage.DbType =DbType.String;
                        if (obj.SECImage == null)
                        {
                            prmSECImage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmSECImage.Value = obj.SECImage;
                        }
                        strWhere += " [SECImage]=@SECImage AND ";
                        lstParameters.Add(prmSECImage);
                     }



                    

                    if (obj.SignImage != "")
                    {
                        DbParameter prmSignImage = con.createParameter();
                        prmSignImage.ParameterName = "@SignImage";
                        prmSignImage.DbType =DbType.String;
                        if (obj.SignImage == null)
                        {
                            prmSignImage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmSignImage.Value = obj.SignImage;
                        }
                        strWhere += " [SignImage]=@SignImage AND ";
                        lstParameters.Add(prmSignImage);
                     }



                    

                    if (obj.StampImage != "")
                    {
                        DbParameter prmStampImage = con.createParameter();
                        prmStampImage.ParameterName = "@StampImage";
                        prmStampImage.DbType =DbType.String;
                        if (obj.StampImage == null)
                        {
                            prmStampImage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmStampImage.Value = obj.StampImage;
                        }
                        strWhere += " [StampImage]=@StampImage AND ";
                        lstParameters.Add(prmStampImage);
                     }



                    

                    if (obj.ManagerPos != "")
                    {
                        DbParameter prmManagerPos = con.createParameter();
                        prmManagerPos.ParameterName = "@ManagerPos";
                        prmManagerPos.DbType =DbType.String;
                        if (obj.ManagerPos == null)
                        {
                            prmManagerPos.Value = DBNull.Value;
                        }
                        else
                        {
                            prmManagerPos.Value = obj.ManagerPos;
                        }
                        strWhere += " [ManagerPos]=@ManagerPos AND ";
                        lstParameters.Add(prmManagerPos);
                     }



                    

                    if (obj.ManagerName != "")
                    {
                        DbParameter prmManagerName = con.createParameter();
                        prmManagerName.ParameterName = "@ManagerName";
                        prmManagerName.DbType =DbType.String;
                        if (obj.ManagerName == null)
                        {
                            prmManagerName.Value = DBNull.Value;
                        }
                        else
                        {
                            prmManagerName.Value = obj.ManagerName;
                        }
                        strWhere += " [ManagerName]=@ManagerName AND ";
                        lstParameters.Add(prmManagerName);
                     }



                    

                    if (obj.ShowStamp != false)
                    {
                        DbParameter prmShowStamp = con.createParameter();
                        prmShowStamp.ParameterName = "@ShowStamp";
                        prmShowStamp.DbType =DbType.Boolean;
                        if (obj.ShowStamp == null)
                        {
                            prmShowStamp.Value = DBNull.Value;
                        }
                        else
                        {
                            prmShowStamp.Value = obj.ShowStamp;
                        }
                        strWhere += " [ShowStamp]=@ShowStamp AND ";
                        lstParameters.Add(prmShowStamp);
                     }



                    

                    if (obj.ShowSignature != false)
                    {
                        DbParameter prmShowSignature = con.createParameter();
                        prmShowSignature.ParameterName = "@ShowSignature";
                        prmShowSignature.DbType =DbType.Boolean;
                        if (obj.ShowSignature == null)
                        {
                            prmShowSignature.Value = DBNull.Value;
                        }
                        else
                        {
                            prmShowSignature.Value = obj.ShowSignature;
                        }
                        strWhere += " [ShowSignature]=@ShowSignature AND ";
                        lstParameters.Add(prmShowSignature);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("AND"));

                    

            

            List<CertificateData> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<CertificateData> Search(CertificateData obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<CertificateData> lstRet = Search(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                

            
public List<CertificateData> SearchOrLike(ClassDataHandler con, CertificateData obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID OR ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.IamLearningImage != "")
                    {
                        DbParameter prmIamLearningImage = con.createParameter();
                        prmIamLearningImage.ParameterName = "@IamLearningImage";
                        prmIamLearningImage.DbType =DbType.String;
                        if (obj.IamLearningImage == null)
                        {
                            prmIamLearningImage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmIamLearningImage.Value = obj.IamLearningImage;
                        }
                        strWhere += " [IamLearningImage] LIKE @IamLearningImage OR ";
                        lstParameters.Add(prmIamLearningImage);
                     }



                    

                    if (obj.SECImage != "")
                    {
                        DbParameter prmSECImage = con.createParameter();
                        prmSECImage.ParameterName = "@SECImage";
                        prmSECImage.DbType =DbType.String;
                        if (obj.SECImage == null)
                        {
                            prmSECImage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmSECImage.Value = obj.SECImage;
                        }
                        strWhere += " [SECImage] LIKE @SECImage OR ";
                        lstParameters.Add(prmSECImage);
                     }



                    

                    if (obj.SignImage != "")
                    {
                        DbParameter prmSignImage = con.createParameter();
                        prmSignImage.ParameterName = "@SignImage";
                        prmSignImage.DbType =DbType.String;
                        if (obj.SignImage == null)
                        {
                            prmSignImage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmSignImage.Value = obj.SignImage;
                        }
                        strWhere += " [SignImage] LIKE @SignImage OR ";
                        lstParameters.Add(prmSignImage);
                     }



                    

                    if (obj.StampImage != "")
                    {
                        DbParameter prmStampImage = con.createParameter();
                        prmStampImage.ParameterName = "@StampImage";
                        prmStampImage.DbType =DbType.String;
                        if (obj.StampImage == null)
                        {
                            prmStampImage.Value = DBNull.Value;
                        }
                        else
                        {
                            prmStampImage.Value = obj.StampImage;
                        }
                        strWhere += " [StampImage] LIKE @StampImage OR ";
                        lstParameters.Add(prmStampImage);
                     }



                    

                    if (obj.ManagerPos != "")
                    {
                        DbParameter prmManagerPos = con.createParameter();
                        prmManagerPos.ParameterName = "@ManagerPos";
                        prmManagerPos.DbType =DbType.String;
                        if (obj.ManagerPos == null)
                        {
                            prmManagerPos.Value = DBNull.Value;
                        }
                        else
                        {
                            prmManagerPos.Value = obj.ManagerPos;
                        }
                        strWhere += " [ManagerPos] LIKE @ManagerPos OR ";
                        lstParameters.Add(prmManagerPos);
                     }



                    

                    if (obj.ManagerName != "")
                    {
                        DbParameter prmManagerName = con.createParameter();
                        prmManagerName.ParameterName = "@ManagerName";
                        prmManagerName.DbType =DbType.String;
                        if (obj.ManagerName == null)
                        {
                            prmManagerName.Value = DBNull.Value;
                        }
                        else
                        {
                            prmManagerName.Value = obj.ManagerName;
                        }
                        strWhere += " [ManagerName] LIKE @ManagerName OR ";
                        lstParameters.Add(prmManagerName);
                     }



                    

                    if (obj.ShowStamp != false)
                    {
                        DbParameter prmShowStamp = con.createParameter();
                        prmShowStamp.ParameterName = "@ShowStamp";
                        prmShowStamp.DbType =DbType.Boolean;
                        if (obj.ShowStamp == null)
                        {
                            prmShowStamp.Value = DBNull.Value;
                        }
                        else
                        {
                            prmShowStamp.Value = obj.ShowStamp;
                        }
                        strWhere += " [ShowStamp]=@ShowStamp OR ";
                        lstParameters.Add(prmShowStamp);
                     }



                    

                    if (obj.ShowSignature != false)
                    {
                        DbParameter prmShowSignature = con.createParameter();
                        prmShowSignature.ParameterName = "@ShowSignature";
                        prmShowSignature.DbType =DbType.Boolean;
                        if (obj.ShowSignature == null)
                        {
                            prmShowSignature.Value = DBNull.Value;
                        }
                        else
                        {
                            prmShowSignature.Value = obj.ShowSignature;
                        }
                        strWhere += " [ShowSignature]=@ShowSignature OR ";
                        lstParameters.Add(prmShowSignature);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("OR"));

                    

            

            List<CertificateData> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<CertificateData> SearchOrLike(CertificateData obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<CertificateData> lstRet = SearchOrLike(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                
        


       
        



    }
}











            